package compare;

import java.util.Set;
import java.util.TreeSet;

public class TestSet {
	public static void main(String[] args) {
		Set<Customer> set = new TreeSet<Customer>();
		
		Customer c1 = new Customer();
		c1.id=1;
		c1.age=21;
		c1.name="abc";
		set.add(c1);
		
		Customer c2 = new Customer();
		c2.id=2;
		c2.age=20;
		c2.name="xyz";
		set.add(c2);
		
		for(Customer c:set){
			System.out.println(c.id+","+c.age+","+c.name);
		}
		
		
		
		Set<Customer> set2 = new TreeSet<Customer>(new AgeComparator());
		set2.add(c1);
		set2.add(c2);
		for(Customer c:set2){
			System.out.println(c.id+","+c.age+","+c.name);
		}
		
		Set<Customer> set3 = new TreeSet<Customer>(new NameComparator());
		set3.add(c1);
		set3.add(c2);
		for(Customer c:set2){
			System.out.println(c.id+","+c.age+","+c.name);
		}
		
		
	}

}
